from rest_framework import serializers
from host.models import Host


class HostSerializer(serializers.ModelSerializer):
    category_name = serializers.CharField(source='category.name')  # 主机分类名

    class Meta:
        model = Host
        fields = ['id', 'category_name', 'hostname', 'ip_addr', 'port', 'desc', ]
